require('../../../lib/tostyle/jquerymin.js')
require('../../../lib/tostyle/icheck.js');

define(['vue','config','common'],function(Vue,config,utils){
	'use strict';

	var BankAccountView=new Vue({
		el:'#app',
		data:{
			realName:'',
			cardno:'',
			banks:'',
			registeredAddress:''
		},
		created:function(){
			$(document).ready(function(){
		        $('.icheckList input').iCheck({
		          checkboxClass: 'icheckbox_square-blue',
		          radioClass: 'iradio_square-blue',
		          increaseArea: '20%'
		        });
          	});
		},
		mounted:function(){

		},
		methods:{
			BankAccountSubmit:function(){
				if($.trim(this.realName) === ""){
					utils.appAlert("请输入银行开户名");
					return;
				}
				if($.trim(this.cardno) === ""){
					utils.appAlert("请输入银行账号");
					return;
				}
				if($.trim(this.banks) === ""){
					utils.appAlert("请输入银行名称");
					return;
				}
				if($.trim(this.registeredAddress) === ""){
					utils.appAlert("请输入支行名称");
					return;
				}
				if($('.icheckList input')[0].checked === false){
					utils.appAlert("请勾选同意《入驻协议》");
					return;
				}
				var url = utils.getWebUrl('shop/update');
				var data = {
					realName: this.realName,
					cardno: this.cardno,
					banks: this.banks,
					registeredAddress: this.registeredAddress
				}
				utils.ajax(url,data,'POST',function(res){
					utils.ajax(utils.getWebUrl('shop/examine'),{},'POST',function(res){
						var auditStatus = res.data.auditStatus;
						switch (auditStatus) {
							case "0":  //不通过
								window.location.href = "shopApplication_verify.html";
								break;
							case "1":   //审核中
								window.location.href = "shopApplication_verify.html";
								break;
							case "2":   //通过
								window.location.href = "userInfo.html";
								break;
						}

					})
					
				})
			}
		}
	})

	return BankAccountView
});